<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2017/6/30
 * Time: 9:16
 * Project name: PHPTEST
 * File name: 1.php
 * @copyright Copyright (c) 2016 ZRX Software LLC
 * @license https://github.com/zhangrxiang
 * @since 1.0.0
 */

$str = "Hello World!";
//foreach ((array)$str as &$value){
//	if($value == 'o'){
//		$value = 'O';
//	}
//}

//////////////////////////////////////////
$l = strlen($str);
for ( $i = 0; $i < $l; $i ++ ) {
	if ( $str{$i} == 'o' ) {
		$str{$i} = 'O';
	}
}
echo $str;
echo PHP_EOL;
//////////////////////////////////////////
echo $str = str_replace('O','o',$str);

///////////////////////////////////////////
while (true){
	if(($p = strpos($str,'o')) !== false){
		$str[$p] = 'O';
	}else
		break;
}
echo PHP_EOL;
echo $str;

